<template>
  <el-form ref="form" :model="loginForm" label-width="80px">
    <el-form-item label="账户">
      <el-input v-model="loginForm.username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="loginForm.password"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>

  import {mapActions,mapGetters} from 'vuex'

  export default {
    data() {
      return {
        loginForm: {
          username: '',
          password: ''
        }
      }
    },
    methods: {
      onSubmit() {
        this.$store.dispatch('Login',this.loginForm).then(() => {
          console.log('end')
        }).catch(() => {
          console.log('error -- end')
        })
      }
    }
  }
</script>
